package com.yjt.javatest.controller;

import com.yjt.javatest.service.LatexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@RestController
@RequestMapping("/latex")
public class LatexController {
    @Autowired
    LatexService latexService;
    @GetMapping(value = "/ltp",produces = MediaType.IMAGE_PNG_VALUE)
    public byte[] latexToPng(@RequestParam String formula, HttpServletResponse response) throws IOException {
        response.setContentType(MediaType.IMAGE_PNG_VALUE);
        return latexService.latexToPng(formula);
    }
}
